package com.tensquare.search.controller;

import com.tensquare.entity.PageResult;
import com.tensquare.entity.Result;
import com.tensquare.entity.StatusCode;
import com.tensquare.search.pojo.Article;
import com.tensquare.search.service.ArticleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author zzb
 * @create 2021/2/22
 */
@RestController
@RequestMapping("article")
public class ArticleController {

    @Autowired
    private ArticleService articleService;
    //根据文章内容和标题分页搜索
    @PostMapping("search/{keywords}/{page}/{size}")
    public Result search(@PathVariable String keywords,@PathVariable Integer page,@PathVariable Integer size){
        //搜索
        PageResult<Article> articlePageResult = articleService.search(keywords,page,size);
        return new Result(true, StatusCode.OK,"根据关键字分页查询成功",articlePageResult);
    }
}
